package exam.gaolingyun.zzptc.com.exam_gaolingyun;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    Timer timer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lll();
    }

    public void lll(){
        SharedPreferences setting = getSharedPreferences("gaolingyun", 0);
        Boolean user_first = setting.getBoolean("FIRST", true);
        if (user_first) {
            // 第一次则跳转到欢迎页面
            setting.edit().putBoolean("FIRST", false).commit();
            TimerTask timerTask=new TimerTask() {
                @Override
                public void run() {
                    Intent intent=new Intent(MainActivity.this,Main2Activity.class);
                    startActivity(intent);
                    MainActivity.this.finish();
                }
            };
            timer.schedule(timerTask,1000*3);
        } else {//如果是第二次启动则直接跳转到主页面
            startActivity(new Intent(this,Main2Activity.class));}
    }

}
